
pkgname=linux-firmware
pkgver=20180606
_b43=5.100.138
_legacy=3.130.20.0
pkgrel=1
pkgdesc="Firmware files for Linux"
arch=('x86_64')
url="http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git"
license=('GPL2' 'GPL3' 'custom')
makedepends=('b43-fwcutter' 'git')
conflicts=('linux-firmware-git'
           'ar9170-fw'
           'carl9170-fw'
           'iwlwifi-1000-ucode'
           'iwlwifi-3945-ucode'
           'iwlwifi-4965-ucode'
           'iwlwifi-5000-ucode'
           'iwlwifi-5150-ucode'
           'iwlwifi-6000-ucode'
           'rt2870usb-fw'
           'rt2x00-rt61-fw'
           'rt2x00-rt71w-fw'
           'b43-firmware'
           'b43-firmware-legacy'
           'amd-ucode')
replaces=('ar9170-fw'
           'carl9170'
           'iwlwifi-1000-ucode'
           'iwlwifi-3945-ucode'
           'iwlwifi-4965-ucode'
           'iwlwifi-5000-ucode'
           'iwlwifi-5150-ucode'
           'iwlwifi-6000-ucode'
           'rt2870usb-fw'
           'rt2x00-rt61-fw'
           'rt2x00-rt71w-fw'
           'b43-firmware'
           'b43-firmware-legacy')
options=(!strip emptydirs)
source=("git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git#branch=master"
        "http://mirror2.openwrt.org/sources/broadcom-wl-${_b43}.tar.bz2"
        "http://downloads.openwrt.org/sources/wl_apsta-${_legacy}.o")
md5sums=('SKIP'
         'f4e357b09eaf5d8b1f1920cf3493a555'
         'e08665c5c5b66beb9c3b2dd54aa80cb3')

package() {
  cd ${pkgname}
  
  make DESTDIR=${pkgdir} install
  rm ${pkgdir}/lib/firmware/{Makefile,README,configure,GPL-3}

  install -d ${pkgdir}/usr/share/licenses/${pkgname}
  install -Dm644 LICEN* WHENCE ${pkgdir}/usr/share/licenses/linux-firmware/

  # microcode reload for older systems not using early
  #install -d ${pkgdir}/usr/lib/tmpfiles.d
  #echo 'w /sys/devices/system/cpu/microcode/reload - - - - 1' \
  #  >${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf

  # install b43-firmware
  b43-fwcutter -w ${pkgdir}/lib/firmware/ ${srcdir}/broadcom-wl-${_b43}/linux/wl_apsta.o

  # install b43-legacy-firmware
  b43-fwcutter -w ${pkgdir}/lib/firmware/ ${srcdir}/wl_apsta-${_legacy}.o
}
